
import { IOptions } from "@/serve";

/**
 * 设置请求域名
 * @param input 
 * @returns 
 */
export function setDomain(input: RequestInfo | URL, domain: string, options?: IOptions): Request {
    if (typeof input === 'string') {
        return new Request(options?.domain || domain + input)
    } else if (input instanceof URL) {
        return new Request(options?.domain || domain + input.toString());
    } else {
        return new Request({ ...input, url: options?.domain || domain + input.url })
    }
}